#include "system-tray-plugin.h"
#include "tray-icon-items-model.h"
#include "ukui-panel-framework/config-loader.h"
#include <QQmlEngine>
#include <QQmlContext>

void SystemTrayPlugin::registerTypes(const char *uri)
{
    Q_ASSERT(QLatin1String(uri) == QLatin1String("org.ukui.systemTray"));

//    qmlRegisterSingletonType<UkuiSystemTray::TrayIconItemsModel>(uri, 1, 0, "ItemModel", [] (QQmlEngine *, QJSEngine *) -> QObject* {
//        return new UkuiSystemTray::TrayIconItemsModel();
//    });
    qmlRegisterType<UkuiSystemTray::GroupModel>(uri, 1, 0, "GroupModel");
}

void SystemTrayPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
{
    Q_ASSERT(QLatin1String(uri) == QLatin1String("org.ukui.systemTray"));
    UkuiSni::StatusNotifierHost::self()->registerHost();

    engine->rootContext()->setContextProperty("ItemModel", new UkuiSystemTray::TrayIconItemsModel);
    engine->rootContext()->setContextProperty("showGroup", new UkuiSystemTray::GroupModel);
    engine->rootContext()->setContextProperty("folderGroup", new UkuiSystemTray::GroupModel);
}
